package com.hualan.zhsq.service.impl.property;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hualan.zhsq.entity.property.ProcessState;
import com.hualan.zhsq.mapper.property.ProcessStateMapper;
import com.hualan.zhsq.service.property.ProcessStateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ProcessServiceImpl
 * @Description 处理状态serviceImpl
 * @Author ZheRan
 * @Date 2025年08月04日 下午8:59
 * @Version 1.0
 */
@Service("processService")
public class ProcessStateServiceImpl implements ProcessStateService {
    @Autowired
    private ProcessStateMapper processStateMapper;

    @Override
    public int add(ProcessState entity) {
        return processStateMapper.insert(entity);
    }

    @Override
    public int edit(ProcessState entity) {
        return processStateMapper.updateById(entity);
    }

    @Override
    public int remove(Integer id) {
        return processStateMapper.deleteById(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return processStateMapper.deleteBatchIds(List.of(ids));
    }

    @Override
    public List<ProcessState> find() {
        return processStateMapper.selectList(null);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ProcessState entity) {
        Page<ProcessState> page = new Page<>( pageNum, pageSize);
        Page<ProcessState> processStatePage = processStateMapper.selectPage(page, null);
        Map<String, Object> map = new HashMap<>();
        map.put("list", processStatePage.getRecords());
        map.put("total", processStatePage.getTotal());
        map.put("size", processStatePage.getSize());
        return map;
    }

    @Override
    public ProcessState findById(Integer id) {
        return processStateMapper.selectById(id);
    }
}
